package com.service.impl;

import com.entity.Employee;
import com.mapper.EmployeeMapper;
import com.service.EmployeeService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Data
@Service // 声明自己是 Service
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired // 自动装配
    private EmployeeMapper employeeMapper;  // 依赖接口

    @Override
    public List<Employee> selectEmployeeAll() {
        return employeeMapper.selectEmployeeAll();
    }

    @Override
    public Employee selectEmployeeByName(String name) {
        return employeeMapper.selectEmployeeByName(name);
    }

    @Override
    public Employee selectEmployeeById(int id) {
        return employeeMapper.selectEmployeeById(id);
    }

    @Override
    public Boolean insertEmployee(Employee employee) {
        return employeeMapper.insertEmployee(employee) > 0;
    }

    @Override
    public Boolean deleteEmployeeById(int id) {
        return employeeMapper.deleteEmployeeById(id) > 0;
    }

    @Override
    public Boolean updateEmployeeById(Employee employee) {
        return employeeMapper.updateEmployeeById(employee) > 0;
    }

}
